<?php
/*
* $Author ：PHPYUN开发团队
*
* 官网: http://www.phpyun.com
*
* 版权所有 2009-2018 宿迁鑫潮信息技术有限公司，并保留所有权利。
*
* 软件声明：未经授权前提下，不得用于商业运营、二次开发以及任何形式的再次发布。
 */
class job_controller extends common{
	function index_action(){
		$CacheM=$this->MODEL('cache');
		$CacheArr=$CacheM->GetCache(array('job','city','hy','com'));
		if($_GET['jobin']){
			$job_classid=@explode(',',$_GET['jobin']);
			$jobname=$CacheArr['job_name'][$job_classid[0]];
			$this->yunset("jobname",mb_substr($jobname,0,6,'utf-8'));
		}
		$uptime=array(1=>'今天',3=>'最近3天',7=>'最近7天',30=>'最近一个月',90=>'最近三个月');
		$this->yunset("uptime",$uptime);
		$this->yunset($CacheArr);
		$this->yunset("headertitle","职位搜索");
		foreach($_GET as $k=>$v){
			if($k!=""){
				$searchurl[]=$k."=".$v;
			}
		}
		$this->seo("com_search");
		$searchurl=@implode("&",$searchurl);
		$this->yunset('backurl',Url('wap'));

		$this->yunset("topplaceholder","请输入职位关键字,如：会计...");
		$this->yunset("searchurl",$searchurl);
		$this->yuntpl(array('wap/job'));
	}
	function search_action(){
		$this->index_action();
	}
	function view_action(){
//	    if( empty($_GET['user_id']) ){
//            $this->ACT_msg($_SERVER['HTTP_REFERER'],"用户参数不能为空！");
//        }
		$user_id_new = $this->getUser( $_GET['user_id'] );

		$this->yunset("user_id",$_GET['user_id']);
		include PLUS_PATH."/com.cache.php";
		$JobM=$this->MODEL('job');
		$CacheM=$this->MODEL('cache');
		$ResumeM=$this->MODEL('resume');
		$UserinfoM=$this->MODEL('userinfo');
		$CacheArr=$CacheM->GetCache(array('job','city','hy','com'));
		$job=$JobM->GetComjobOne(array("id"=>(int)$_GET['id'],'`r_status`<>2'));
		$entry_info=$this->obj->DB_select_once("entry","`job_id`='".$_GET['id']."' AND `member_id`='".$user_id_new['user_id']."'");
		$this->yunset("entry_info",$entry_info);
//            if($job['status']=="1"){
//                $this->ACT_msg($_SERVER['HTTP_REFERER'],"该职位已下架！");
//            }
		$is_toudi=$JobM->GetUserJobNum(array("job_id"=>(int)$_GET['id'],"user_id"=>$user_id_new['user_id']));
		$this->yunset("is_toudi",$is_toudi);
		//include(CONFIG_PATH."db.data.php");
		$this->yunset("arr_data",$arr_data);

		if($job['lang']){
			$lang = @explode(",",$job['lang']);
			$job['lang']=$lang;
		}
		if($job['bright']){
			$lang = @explode(",",$job['bright']);
			$job['bright']=$lang;
			foreach ( $comdata['job_bright'] as $k=> $v ){
				if( in_array( $v, $job['bright'] ) ){
					$bright[] = $comclass_name[$v];
				}
			}
		}
		$this->yunset("bright",$bright);
		if($job['welfare_other']){
			$lang = @explode(",",$job['welfare_other']);
			$job['welfare_other']=$lang;
			foreach ( $comdata['welfare_other'] as $k=> $v ){
				if( in_array( $v, $job['welfare_other'] ) ){
					$welfare_other[] = $comclass_name[$v];
				}
			}
		}
		//是否为名企
		if( $job['f_company'] ){
			$job['f_company'] = ($job['f_company'] == 1) ? '是' : '否';
		}
		//发放方式
		//if( $job['salary_type'] ){
			//$job['salary_type'] = ($job['salary_type'] == 0) ? '暂无' : ($job['salary_type'] == 1) ? '日薪' : (($job['salary_type'] == 2) ? '周薪' : (($job['salary_type'] == 3) ? '月薪' : (($job['salary_type'] == 4) ? '月双薪' : '暂无')));
			switch ($job['salary_type']) {
				case '0';
					$job['salary_type'] = '暂无';
					$type = '未知';
					break;
				case '1';
					$job['salary_type'] = '日薪';
					$type = '日';
					break;
				case '2';
					$job['salary_type'] = '周薪';
					$type = '周';
					break;
				case '3';
					$job['salary_type'] = '月薪';
					$type = '月';
					break;
				case '4';
					$job['salary_type'] = '日薪';
					$type = '小时';
					break;
				case '5';
					$job['salary_type'] = '月三薪';
					break;
			}

		if($job['discuss'] ==1){
			$job['salary'] = '面议';
		}else{
			if($job['minsalary'] == $job['maxsalary']){
				$job['salary'] = $job['minsalary'].' 元/'.$type;
			}else{
				$job['salary'] = $job['minsalary'].' ~ '.$job['maxsalary'].' 元/'.$type;
			}
		}
		//}
		$this->yunset("welfare_other",$welfare_other);
		//获取公司的信息
		//2019/4/16 替换跨库为java接口
		$yingpin_model = $this->MODEL('yingpin');
		$company_info = $yingpin_model->getCompanyOnce($job['company_id']);
//		$company_info = $this->objlan->DB_select_once('t_enterprise',"`enterprise_id`='".$job['company_id']."'","*");
		$company_img_info = $yingpin_model->getCompanyImage($job['company_id']);
//		$company_img_info = $this->objlan->DB_select_all('enterprise_oss',"`enterprise_id`='".$job['company_id']."'","url");
		$this->yunset("company_info",$company_info);
		$this->yunset("company_img_info",$company_img_info);
		//获取公司其他的职位
		$other_job=$this->obj->DB_select_all("company_job","`company_id`='".$job['company_id']."' and `status`!= 1 AND `id` NOT IN ('".$job['id']."') order by `sdate` desc limit 2");
		//判断查询到的公司其他职位是否被投递
		$userid_jobs = $this->obj->DB_select_all("userid_job"," 1 and `com_id`='".$job['company_id']."' and `user_id`='".$user_id_new['user_id']."'","id,job_id");
		if(!empty($other_job) && !empty($userid_jobs)){
			foreach($other_job as $k=>$v){
				foreach($userid_jobs as $k2=>$v2){
					if($v['id'] == $v2['job_id']){
						$other_job[$k]['types'] = 1;
					}else{
						$other_job[$k]['types'] = 0;
					}
				}
			}
		}
		$this->yunset("other_job",$other_job);
		$userid_job=$this->obj->DB_select_num("userid_job","`job_id`='".(int)$_GET['id']."'");
		$fav_job=$this->obj->DB_select_num("fav_job","`job_id`='".(int)$_GET['id']."'and `uid`='".$user_id_new['user_id']."'");
		$job['fav_job']=$fav_job;
//		$welfare = @explode(",",$company['welfare']);
//		  foreach($welfare as $k=>$v){
//			if(!$v){
//			  unset($welfare[$k]);
//			}
//		  }
//		$job['welfare']=$welfare;

		$job['description']=str_replace(array("ti<x>tle","“","”"),array("title"," "," "),$job['description']);
		$job['description']=htmlspecialchars_decode($job['description']);
		preg_match_all('/<img(.*?)src=("|\'|\s)?(.*?)(?="|\'|\s)/',$job['description'],$res);
		if(!empty($res[3])){
			foreach($res[3] as $v){
				if(strpos($v,'http:')===false && strpos($v,'https:')===false){
					$job['description'] = str_replace($v,$this->config['sy_weburl'].$v,$job['description']);
				}
			}
		}
//		$Info=array_merge_recursive($job,$company);
//		if($Info['linkman']){
//			$operatime=time()-$Info['operatime'];
//			if($Info['operatime']==''){
//				$Info['operatime']='0';
//			}else if($operatime<3600){
//				$Info['operatime']='一小时以内';
//			}else if($operatime>=3600&&$operatime<86400){
//				$Info['operatime']=floor($operatime/3600).'小时';
//			}else if($operatime>=86400){
//				$Info['operatime']=floor($operatime/86400).'天';
//			}
//			$allnum=$JobM->GetUserJobNum(array("com_id"=>$Info['uid'],"job_id"=>$Info['id']));
//			$replynum=$JobM->GetUserJobNum(array("com_id"=>$Info['uid'],"job_id"=>$Info['id'],"`is_browse`>'1'"));
//
// 			if($allnum==0){
// 				$this->yunset("pre",0);
// 			}else{
// 				$pre=round(($replynum / $allnum)*100);
//				$this->yunset("pre",$pre);
// 			}
//
//		}
//		$comrat=$UserinfoM->GetRatinginfoOne(array("id"=>$job['rating']));
//		if($comrat['com_pic']&&file_exists(str_replace('./',APP_PATH.'/',$comrat['com_pic']))){
//			$comrat['com_pic']=str_replace('./',$this->config['sy_weburl'].'/',$comrat['com_pic']);
//		}else{
//			$comrat['com_pic']='';
//		}
		//todo
//		if($this->usertype=="1"&&$this->uid){
//			$ResumeM=$this->MODEL('resume');
//			$resume=$ResumeM->GetResumeExpectNum(array('uid'=>$this->uid,"`r_status`<>'2' and `job_classid`<>''","open"=>'1'));
//			if($resume){
//
//				$look_job=$JobM->GetLookJobOne(array("jobid"=>(int)$_GET['id']));
//				if(!empty($look_job)){
//					$JobM->UpdateLookJob(array("datetime"=>time()),array("jobid"=>(int)$_GET['id']));
//				}else{
//
//					$value['uid']='';
//					$value['did']=$this->userdid;
//					$value['jobid']=(int)$_GET['id'];
//					$value['com_id']=$job['uid'];
//					$value['datetime']=time();
//					$JobM->AddLookJob($value);
//				}
//			}
//		}
		$yingpin_model = $this->MODEL('yingpin');
		if($_GET['type']){
			if($_GET['type']=='sq'){
				if( $job['status'] == 1 ){
					$data['msg']='该职位已下架！';
					$data['url']=$_SERVER['HTTP_REFERER'];

					$message = '您的简历已投递';
					$detail = '您的简历投递失败，该职位已下架';
					$value_app = array();
					$value_app['title']=$message;
					$value_app['details']=$detail;
					$value_app['msgType']="1";
					$value_app['status']="0";
					$value_app['userId']=$user_id_new['user_id'];
					$value_app['createTime']=date("Y-m-d H:i:s");
					//2019/4/16 替换跨库为java接口
					$a = $yingpin_model->addMessageLog($value_app);
//					$a = $this->objlan->DB_insert_once("app_message_log",$value_app);

					echo json_encode($data);die;
				}
				$row=$JobM->GetUserJobNum(array("job_id"=>(int)$_GET['id'],"user_id"=>$user_id_new['user_id']));
				if(intval($row)>0){
					$data['msg']='您已经投递过该简历，请不要重复投递！';
					$data['url']=$_SERVER['HTTP_REFERER'];

					echo json_encode($data);die;
				}else{
					$info=$JobM->GetComjobOne(array("id"=>(int)$_GET['id']));
					$value['job_id']=$_GET['id'];
					$value['user_id']=$user_id_new['user_id'];
					$value['com_name']=$info['com_name'];
					$value['job_name']=$info['name'];
					$value['com_id']=$info['company_id'];
					$value['company_logo']=$company_info['company_logo'];
					$value['datetime']=mktime();
					$nid=$JobM->AddUseridJob($value);
//                            $member_info = $this->objlan->DB_select_once('app_user',"`user_id`='".$_GET['user_id']."'","*");
//                            if( empty( $member_info ) ){
//                                $data['msg']='用户信息没有获取成功！';
//                                $data['url']=$_SERVER['HTTP_REFERER'];
//                                echo json_encode($data);die;
//                            }
					//查询经纪人信息   star==========================
					//2019/4/16 替换跨库为java接口
					$agent_id= $yingpin_model->getBusinessOnce($_GET['user_id']);
//					$where = " 1";
//					$where .= " and `user_id`=".$_GET['user_id'];
//					$agent_id= $this->objlan->DB_select_once("agent_business",$where,"`agent_id`");
					//经纪人信息  end================================
					$value = '';
					$value.="`company_id`='".$job['company_id']."',";
					$value.="`company_name`='".$job['com_name']."',";
					$value.="`job_id`='".$_GET['id']."',";
					$value.="`job_name`='".$job['name']."',";
					$value.="`member_id`='".$user_id_new['user_id']."',";
					$value.="`nickname`='".$user_id_new['username']."',";
					$value.="`member_name`='".$user_id_new['realname']."',";
					$value.="`member_phone`='".$user_id_new['mobile']."',";
					$value.="`member_card`='".$user_id_new['idcard']."',";
					$value.="`member_sex`='".$user_id_new['sex']."',";
					$value.="`current_residence`='".$user_id_new['current_residence']."',";
					$value.="`expected_working_city`='".$user_id_new['expected_working_city']."',";
					$value.="`user_avatar`='".$user_id_new['user_avatar']."',";
					$value.="`birthday`='".$user_id_new['birthday']."',";
					$value.="`agent_id`='".$agent_id['agent_id']."',";
					$value.="`add_time`='".time()."'";
					$res = $this->obj->DB_insert_once("entry",$value);
					$id = (int)$_GET['id'];
					$sql = "update `phpyun_company_job` set `jobhits` = `jobhits`+1 WHERE `id` = $id ";
					$resb = $this->db->query( $sql );
					if( $resb ){
						$data['msg']='投递成功！';
						$data['url']=$_SERVER['HTTP_REFERER'];

						//投递成攻给王传数据
						//2019/4/16 替换跨库为java接口
						$condition = array();
						$condition['status'] = "2";
						$condition['statusValue'] = "待入职";
						$bid = $yingpin_model->editBusinessOnce($condition);
//						$condition = '';
//						$condition .= "`status`='2',";
//						$condition .= "`status_value`='待入职',";
//						$bid = $this->objlan->DB_update_all("app_recommend", $condition, " `is_recommended_mobile`='" . $user_id_new['mobile']. "'");

						//新增收藏加积分功能   2019.2.27 ======================== s

						//查询今天该用户的浏览+积分的计数
						$where = " 1";
						$where .= " and `uid`=".$user_id_new['user_id'];
						$where .= " and `state`=5";
						$where .= " and `ctime` BETWEEN '".strtotime(date("Y-m-d"))."' and '".(strtotime(date("Y-m-d"))+86400)."' ";
						$browse_num = $this->obj->DB_select_num("member_reg",$where);
						$data['msg']='收藏成功！';
						if($browse_num >= 2){
							$data['msg']='投递成功！';
						}else{
							//每天少于2则进行记录，添加积分
							$data = array();
							$data['uid'] = $user_id_new['user_id'];
							$data['date'] = date("Y-m-d");
							$data['usertype'] = 1;//app来源
							$data['ip'] = fun_ip_get();
							$data['ctime'] = time();
							$data['job_id'] = $_GET['id'];
							$data['integral'] = 10;//积分数量
							$data['msg'] = "每日投递岗位";
							$data['state'] = 5;
							$aid=$this->obj->insert_into('member_reg',$data);
							//添加成功进行积分添加

							//查询是否有该用户
							$info = $this->obj->DB_select_once("member_statis","`uid`='".$user_id_new['user_id']."'");
							if( empty( $info ) ){
								$uid = $this->obj->insert_into("member_statis",array("uid"=>$user_id_new['user_id'],'integral'=>$data['integral']));
							}else{
								$uid = $this->obj->DB_update_all('member_statis',"`integral`=`integral`+'".$data['integral']."'","`uid`='".$user_id_new['user_id']."'");
							}
							if($uid){
								$data['msg']='投递成功，积分+15！';
							}else{
								$data['msg']='投递成功！';
							}

						}

						//jifen  =============================================== e
					}else{
						$data['msg']='投递失败！增加job投递数错误';
						$data['url']=$_SERVER['HTTP_REFERER'];
					}
					$message = '您的简历已投递';
					$detail = '您的简历已投递成功，请等待'.$job['com_name'].'的处理';
					$value_app = array();
					$value_app['title']=$message;
					$value_app['details']=$detail;
					$value_app['msgType']="1";
					$value_app['status']="1";
					$value_app['userId']=$user_id_new['user_id'];
					$value_app['createTime']=date("Y-m-d H:i:s");
					$a = $yingpin_model->addMessageLog($value_app);
//					$a = $this->objlan->DB_insert_once("app_message_log",$value_app);
					//增加积分
//					$member_jifen_info = $this->obj->DB_select_once('member_reg',"`uid`='".$user_id_new['user_id']."' AND msg `like` '%投递%'","*");
//					$date = date('Y-m-d',time());
//					if( empty( $member_jifen_info ) ){
//						//如果一次都没有投递过 积分+50
//						$integral = 50;
//						$this->obj->insert_into("member_reg",array("uid"=>$user_id_new['user_id'],'date'=>$date,"ctime"=>time(),'ip'=>fun_ip_get(),'integral'=>$integral,'msg'=>'投递职位'));
//						$info = $this->obj->DB_select_once("member_statis","`uid`='".$user_id_new['user_id']."'");
//						if( empty( $info ) ){
//							$this->obj->insert_into("member_statis",array("uid"=>$user_id_new['user_id'],'integral'=>$integral));
//						}else{
//							$this->obj->DB_update_all('member_statis',"`integral`=`integral`+'".$integral."'","`uid`='".$user_id_new['user_id']."'");
//						}
//					}else{
//						//今天是否投递
//						$member_jifen_info_today = $this->obj->DB_select_once('member_reg',"`uid`='".$user_id_new['user_id']."' AND msg `like` '%投递%' AND `date` = '".$date."'","*");
//						if( empty($member_jifen_info_today) ){
//							$integral = 10;
//							$this->obj->insert_into("member_reg",array("uid"=>$user_id_new['user_id'],'date'=>$date,"ctime"=>time(),'ip'=>fun_ip_get(),'integral'=>$integral,'msg'=>'投递职位'));
//							$this->obj->DB_update_all('member_statis',"`integral`=`integral`+'".$integral."'","`uid`='".$user_id_new['user_id']."'");
//						}
//					}

					echo json_encode($data);die;
				}
			}else if($_GET['type']=='fav'){
				$rows=$ResumeM->GetFavjobOne(array("uid"=>$user_id_new['user_id'],'job_id'=>(int)$_GET['id']));
				if($rows['id']){
					$data['msg']='您已经收藏过该职位，请不要重复收藏！';
					$data['url']=$_SERVER['HTTP_REFERER'];

					echo json_encode($data);die;
				}
				$job=$JobM->GetComjobOne(array("id"=>(int)$_GET['id']));
				$value['job_id'] = $_GET['id'];
				$value['com_name'] = $job['com_name'];
				$value['job_name'] = $job['name'];
				$value['com_id'] = $job['company_id'];
				$value['uid'] = $user_id_new['user_id'];
				$value['company_logo']=$company_info['company_logo'];
				$value['datetime'] = time();
				$nid=$JobM->AddFavJob($value);
				//新增收藏加积分功能   2019.2.27 ======================== s

				//查询今天该用户的浏览+积分的计数
				$where = " 1";
				$where .= " and `uid`=".$user_id_new['user_id'];
				$where .= " and `state`=4";
				$where .= " and `ctime` BETWEEN '".strtotime(date("Y-m-d"))."' and '".(strtotime(date("Y-m-d"))+86400)."' ";
				$browse_num = $this->obj->DB_select_num("member_reg",$where);
				$data['msg']='收藏成功！';
				if($browse_num >= 2){
					$data['msg']='收藏成功！';
				}else{
					//每天少于2则进行记录，添加积分
					$data = array();
					$data['uid'] = $user_id_new['user_id'];
					$data['date'] = date("Y-m-d");
					$data['usertype'] = 1;//app来源
					$data['ip'] = fun_ip_get();
					$data['ctime'] = time();
					$data['job_id'] = $_GET['id'];
					$data['integral'] = 10;//积分数量
					$data['msg'] = "每日收藏岗位";
					$data['state'] = 4;
					$aid=$this->obj->insert_into('member_reg',$data);
					//添加成功进行积分添加

					//查询是否有该用户
					$info = $this->obj->DB_select_once("member_statis","`uid`='".$user_id_new['user_id']."'");
					if( empty( $info ) ){
						$uid = $this->obj->insert_into("member_statis",array("uid"=>$user_id_new['user_id'],'integral'=>$data['integral']));
					}else{
						$uid = $this->obj->DB_update_all('member_statis',"`integral`=`integral`+'".$data['integral']."'","`uid`='".$user_id_new['user_id']."'");
					}
					if($uid){
						$data['msg']='收藏成功，积分+10！';
					}else{
						$data['msg']='收藏成功！';
					}

				}

				//jifen  =============================================== e

//					if($nid){
				//$data['msg']='收藏成功！';
				$data['url']=$_SERVER['HTTP_REFERER'];
				echo json_encode($data);die;
//					}else{
//						$data['msg']='收藏失败！';
//						$data['url']=$_SERVER['HTTP_REFERER'];
//						echo json_encode($data);die;
//					}
			}else if($_GET['type']=='favcancel'){
				$rows=$ResumeM->GetFavjobOne(array("uid"=>$user_id_new['user_id'],'job_id'=>(int)$_GET['id']));
				if($rows['id']){
					$this->obj->DB_delete_all("fav_job","`id`='".$rows['id']."'","");
					$data['msg']='取消收藏成功！';
					$data['url']=$_SERVER['HTTP_REFERER'];
					echo json_encode($data);die;
				}else{
					$data['msg']='您未收藏过该职位！';
					$data['url']=$_SERVER['HTTP_REFERER'];

					echo json_encode($data);die;
				}
			}
		}
		$data['job_class']=$CacheArr['job_name'][$job['job1']].",".$CacheArr['job_name'][$job['job1_son']].",".$CacheArr['job_name'][$job['job_post']];
		$data['job_desc']=$this->GET_content_desc($job['description']);
		$this->data=$data;
		if(strpos($_SERVER['HTTP_REFERER'],'ajaxreward')||strpos($_SERVER['HTTP_REFERER'],'sqreward')){
			$backurl = Url('wap',array('c'=>'job'));
			$this->yunset("backurl",$backurl);
		}
		$job['sex'] =$arr_data['sex'][$job['sex']];
		$this->seo("comapply");
		$this->yunset("job",$job);
		$address = $CacheArr['city_name'][$job['provinceid']].'省'.$CacheArr['city_name'][$job['cityid']].'市'.$CacheArr['city_name'][$job['three_cityid']].$job['address'];
		$this->yunset("address",$address);
		$this->yunset($CacheArr);
		$a = $company_info['enterprise_abbreviation']?$company_info['enterprise_abbreviation']:$company_info['enterprise_name'];
		$this->yunset("headertitle",$company_info['enterprise_abbreviation']?$company_info['enterprise_abbreviation']:$company_info['enterprise_name']);
		$this->yunset("shareurl",Url('wap',array('c'=>'job','a'=>'share','id'=>$job['id'])));
		$user_agent = ( !isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
		if ($_GET['mapx']>0 && $_GET['mapy']>0 && strpos($user_agent, 'Android') && is_weixin()){
			$distance=$this->GetDistance($_GET['mapx'], $_GET['mapy'], $job['x'], $job['y']);
			if($distance<=1){
				$distance=ceil($distance*1000).'m';
			}else{
				$distance=round($distance, 2).'km';
			}
			$this->yunset(array('mapx'=>$_GET['mapx'],'mapy'=>$_GET['mapy'],'distance'=>$distance));
		}else{
			$this->yunset(array('mapx'=>0,'mapy'=>0));
		}
		$this->yuntpl(array('wap/job_show'));
	}

	function report_action(){
		if($this->usertype!='1'){
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='只有个人会员才可举报！';
			echo json_encode($data);die;
		}
		$M=$this->MODEL('job');
		$AskM=$this->MODEL('ask');
		$jobid=intval($_POST['id']);
		session_start();

		$job=$M->GetComjobOne(array("id"=>$jobid),array('field'=>'`uid`,`com_name`'));
		if($job['uid']==''){
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='非法操作！';
			echo json_encode($data);die;
		}
		if($this->config['user_report']!='1'){
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='管理员未开启举报功能！';
			echo json_encode($data);die;
		}
		if(md5(strtolower($_POST['authcode']))!=$_SESSION['authcode'] || empty($_SESSION['authcode'])){
			unset($_SESSION['authcode']);
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='验证码错误！';
			echo json_encode($data);die;
		}
		$row=$AskM->GetReportOne(array('p_uid'=>$this->uid,'eid'=>(int)$_POST['id'],'c_uid'=>$job['uid'],'usertype'=>$this->usertype));
		if(is_array($row)){
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='您已举报过该用户！';
			echo json_encode($data);die;
		}
		$data=array('c_uid'=>$job['uid'],'inputtime'=>time(),'p_uid'=>$this->uid,'usertype'=>(int)$this->usertype,'eid'=>$jobid,'r_name'=>$job['com_name'],'username'=>$this->username,'r_reason'=>trim($_POST['reason']),'did'=>$this->userdid);
		$nid=$AskM->AddReport($data);
		if($nid){
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='举报成功！';
			echo json_encode($data);die;
		}else{
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='举报失败！';
			echo json_encode($data);die;
		}
	}
	function ltjob_action(){
		$LietouM=$this->MODEL('lietou');
		$CacheM=$this->MODEL('cache');
		$CacheArr=$CacheM->GetCache(array('lt','city','lthy','ltjob'));
		$job=$LietouM->GetLietoujobOne(array("id"=>(int)$_GET['id']));
		if($job['uid']){
			$info=$LietouM->GetLtinfo(array("uid"=>$job['uid']));
			$this->yunset("info",$info);
		}
		$social = @explode(",",$job['social']);
		foreach($social as $k=>$v){
			if(!$v){
				unset($social[$k]);
			}
		}
		$language = @explode(",",$job['language']);
		foreach($language as $k=>$v){
			if(!$v){
				unset($language[$k]);
			}
		}
		$job['language']=$language;
		$job['social']=$social;
		$lang = @explode(",",$job['lang']);
		$job['lang']=$lang;
		$this->yunset($CacheArr);
		$this->yunset("title",$job['job_name']);
		$this->yunset("job",$job);
		$this->yunset("headertitle","职位详情");
		$this->yunset("shareurl",Url('wap',array('c'=>'ltjob','a'=>'share','id'=>$job['id'])));
		$this->yuntpl(array('wap/ltjob'));
	}
	function applyjobuid_action(){
		include(CONFIG_PATH."db.data.php");
		unset($arr_data['sex'][3]);
		$this->yunset("arr_data",$arr_data);
		$CacheM=$this->MODEL('cache');
		$CacheList=$CacheM->GetCache(array('job','city','com','user','hy'));
		$JobM=$this->MODEL('job');
		if(intval($_GET['jobid'])&&intval($_GET['id'])){
			$Resume=$this->MODEL("resume");
			$row=$Resume->SelectTemporaryResume(array("id"=>intval($_GET['id'])));
			$jobids=@explode(',',$row['job_classid']);
			$jobname=array();
			foreach($jobids as $v){
				$jobname[]=$CacheList['job_name'][$v];
			}
			$row['jobname']=@implode('、',$jobname);
			$this->yunset('row',$row);
		}
		$job=$JobM->GetComjobOne(array("id"=>(int)$_GET['jobid']));
		$data['job_name']=$job['name'];
		$data['company_name']=$job['com_name'];
		$data['job_desc']=$this->GET_content_desc($job['description']);
		$this->data=$data;
		$this->seo("comapply");
		$this->yunset('job',$job);
		$this->yunset($CacheList);
		$this->yunset("headertitle","快速申请");
		$this->yuntpl(array('wap/applyjobuid'));
	}
	function applylogin_action(){
		$CacheM=$this->MODEL('cache');
		$CacheList=$CacheM->GetCache(array('job','city','com','user','hy'));
		$JobM=$this->MODEL('job');
		$job=$JobM->GetComjobOne(array("id"=>(int)$_GET['jobid']));
		$data['job_name']=$job['name'];
		$data['company_name']=$job['com_name'];
		$data['job_desc']=$this->GET_content_desc($job['description']);
		$this->data=$data;
		$this->seo("comapply");
		$this->yunset('job',$job);
		$this->yunset($CacheList);
		$url=Url('wap',array("c"=>"job","a"=>"applyjobuid",'jobid'=>intval($_GET['jobid']),"id"=>intval($_GET['id'])));
		$this->yunset('backurl',$url);
		$this->yunset("headertitle","设置密码");
		$this->yuntpl(array('wap/applylogin'));
	}
	function share_action(){
		$this->get_moblie();
		include(CONFIG_PATH."db.data.php");
		$this->yunset("arr_data",$arr_data);
		$JobM=$this->MODEL('job');
		$CacheM=$this->MODEL('cache');
		$UserinfoM=$this->MODEL('userinfo');
		$CacheArr=$CacheM->GetCache(array('job','city','hy','com'));
		$job=$JobM->GetComjobOne(array("id"=>(int)$_GET['id']));

		$lang = @explode(",",$job['lang']);
		$job['lang']=$lang;
		$job['sex']=$arr_data['sex'][$job['sex']];
		$company=$UserinfoM->GetUserinfoOne(array("uid"=>$job['uid']),array("usertype"=>'2','field'=>'*'));
		$welfare = @explode(",",$company['welfare']);
		foreach($welfare as $k=>$v){
			if(!$v){
				unset($welfare[$k]);
			}
		}
		$job['welfare']=$welfare;

		if($company['linkphone']){
			$company['phone']=str_replace('-','',$company['linkphone']);
		}
		$company['content']=strip_tags($company['content']);
		$job['description']=strip_tags($job['description'],"<br>");

		if ($company['infostatus']==1){
			if($this->uid!=$job['uid']){
				if($this->config['com_login_link']=="2"){
					$look_msg=4;
				}elseif($this->config['com_login_link']=="3"){
					if($this->uid=="" && $this->username==""){
						$look_msg=1;
					}else{
						if($this->usertype!="1"){
							$look_msg=2;
						}
					}
					if($this->config['com_resume_link']=="1"&&$this->usertype=='1'){
						$ResumeM=$this->MODEL('resume');
						$row=$ResumeM->GetResumeExpectNum(array("uid"=>$this->uid));
						if($row<1){
							$look_msg=3;
						}
					}
				}
			}
			if($job['is_link']=="1"){
				if($job['link_type']==2){
					$link=$JobM->GetComjoblinkOne(array('jobid'=>$job['id']),array('field'=>'`link_man`,`link_moblie`'));
					$job['linkman']=$link['link_man'];
					if($link['link_moblie']){
						if($look_msg==1){
							$job['linktel']= substr_replace($link['link_moblie'],'****',4,4);
						}else{
							$job['linktel']=$link['link_moblie'];
						}
					}
				}else{
					$job['linkman']=$company['linkman'];
					if($company['linktel']){
						if($look_msg==1){
							$job['linktel']= substr_replace($company['linktel'],'****',4,4);
						}else{
							$job['linktel']=$company['linktel'];
						}
					}
				}
			}else{
				$look_msg=4;
			}
		}else{
			$look_msg=4;
		}

		$this->yunset("look_msg",$look_msg);
		$this->yunset("job",$job);
		$this->yunset($CacheArr);
		$this->yunset("company",$company);
		$data['job_name']=$job['name'];
		$data['company_name']=$job['com_name'];
		$data['industry_class']=$CacheArr['industry_name'][$job['hy']];
		$data['job_class']=$CacheArr['job_name'][$job['job1']].",".$CacheArr['job_name'][$job['job1_son']].",".$CacheArr['job_name'][$job['job_post']];
		$data['job_desc']=$this->GET_content_desc($job['description']);
		$this->data=$data;
		$this->seo("comapply");

		$this->yunset("headertitle",$job['name'].'-'.$job['com_name'].'-'.$this->config['sy_webname']);

		$this->yunset("job_style",$this->config['sy_weburl']."/app/template/wap/job");
		$this->yuntpl(array('wap/job/index'));
	}
	function GetHits_action() {
		if(intval($_GET['id'])){
			$JobM=$this->MODEL('job');
			$JobM->UpdateComjob(array("`jobhits`=`jobhits`+1"),array("id"=>(int)$_GET['id']));
			$hits=$JobM->GetComjobOne(array('id'=>intval($_GET['id'])),array('field'=>'jobhits'));
			echo 'document.write('.$hits['jobhits'].')';
		}
	}
	function msg_action(){

		if($this->uid==''||$this->username==''){
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='请先登录！';
			echo json_encode($data);die;
		}
		if($this->usertype!="1"){
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='只有个人用户才可以留言！';
			echo json_encode($data);die;
		}
		$M=$this->MODEL("job");
		$black=$M->GetBlackOne(array('p_uid'=>$this->uid,'c_uid'=>(int)$_POST['job_uid']));
		if(!empty($black)){
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='该企业暂不接受相关咨询！';
			echo json_encode($data);die;
		}
		if(trim($_POST['reason'])==""){
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='留言内容不能为空！';
			echo json_encode($data);die;
		}
		if(trim($_POST['authcode'])==""){
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='验证码不能为空！';
			echo json_encode($data);die;
		}
		session_start();
		if(md5(strtolower($_POST['authcode']))!=$_SESSION['authcode'] || empty($_SESSION['authcode'])){
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='验证码错误！';
			echo json_encode($data);die;
		}
		$id=$M->AddMsg(array('uid'=>$this->uid,'username'=>$this->username,'jobid'=>trim($_POST['jobid']),'job_uid'=>trim($_POST['job_uid']),'content'=>trim($_POST['reason']),'com_name'=>trim($_POST['com_name']),'job_name'=>trim($_POST['job_name']),'type'=>'1','datetime'=>time()));
		if($id){
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='留言成功，请等待回复！';
			echo json_encode($data);die;
		}else{
			$data['url']=$_SERVER['HTTP_REFERER'];
			$data['msg']='留言失败！';
			echo json_encode($data);die;
		}
	}
	function jobmap_action(){
		$this->get_moblie();
		$this->yunset("title","工作地点");
		$comid = intval($_GET['id']);
		$companyM = $this->MODEL('company');
		$com = $this->obj->DB_select_once("company_job","`id`='".$_GET['id']."'");
//	    $com = $companyM->GetCompanyInfo(array('uid'=>$comid),array('field'=>'`uid`,`name`,`cityid`,`address`,`x`,`y`'));
		$CacheM=$this->MODEL('cache');
		$CacheArr=$CacheM->GetCache(array('city'));
		$cityname = $CacheArr['city_name'][$com['cityid']];
		$address = $CacheArr['city_name'][$com['provinceid']].'省'.$CacheArr['city_name'][$com['cityid']].'市'.$CacheArr['city_name'][$com['three_cityid']];
		$this->yunset("address",$address);
		$this->yunset('cityname',$cityname);
		$this->yunset('com',$com);
		$user_agent = ( !isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
		if ($_COOKIE['mapx']>0 && $_COOKIE['mapy']>0 ){
			$this->yunset(array('mapx'=>$_COOKIE['mapx'],'mapy'=>$_COOKIE['mapy']));
		}else{
			$this->yunset(array('mapx'=>0,'mapy'=>0));
		}
//		$this->yuntpl(array('wap/job_map'));
		if($_GET['type'] == 'bus'){
			$this->yuntpl(array('wap/map_bus'));
		}elseif($_GET['type'] == 'car'){
			$this->yuntpl(array('wap/map_car'));
		}elseif($_GET['type'] == 'footer'){
			$this->yuntpl(array('wap/map_footer'));
		}elseif($_GET['type'] == 'ride'){
			$this->yuntpl(array('wap/map_ride'));
		}else{
			$this->yuntpl(array('wap/map_company'));
		}

	}

	function distance_action(){
		$x = $_POST['x'];
		$y = $_POST['y'];
		$this->cookie->setcookie('mapx', $x, time()+600);
		$this->cookie->setcookie('mapy', $y, time()+600);
	}
	function GetDistance($lat1, $lng1, $lat2, $lng2){
		define('PI',3.1415926535898);
		define('EARTH_RADIUS',6378.137);
		$radLat1 = $lat1 * (PI / 180);
		$radLat2 = $lat2 * (PI / 180);

		$a = $radLat1 - $radLat2;
		$b = ($lng1 * (PI / 180)) - ($lng2 * (PI / 180));

		$s = 2 * asin(sqrt(pow(sin($a/2),2) + cos($radLat1)*cos($radLat2)*pow(sin($b/2),2)));
		$s = $s * EARTH_RADIUS;
		$s = round($s * 10000) / 10000;
		return $s;
	}

	//蓝领网新增条件接口
	function condition_action(){

		$data = array();
		$msg = 'success';
		$code = 0;
		//测试
		//$_GET['city'] = 370200;

		$CacheM=$this->MODEL('cache');
		$condition=$CacheM->GetCache(array('com','user','city'));
		//地区
//		$area = array();
//		if($_GET['city']){
//			$areas = $this->objlan->DB_select_all("t_area_city","`pid`='".(int)$_GET['city']."'");
//			foreach($areas as $k=>$v){
//				$area[$k]['name'] = $v['name'];
//				$area[$k]['id'] = $v['id'];
//			}
//		}else{
//			$msg = '未接收到城市id';
//			$code = 1;
//		}
//		$data[0]['value'] = $area;
//		$data[0]['type'] = '全市';

		$area = array();
		//if($_GET['city']) {
		//处理城市名称问题 先取带‘市’的
		$city_id = '';
		foreach($condition['city_name'] as $key=>$value){
			if($value == $_GET['city']){
				$city_id = $key;
				break;
			}
		}
		$area[0]['name'] = "全市";
		$area[0]['id'] = 0;
		//查询不到相关id则截取字符‘市’进行二次查询
		if($city_id){
			if ($condition['city_type'][$city_id] && $condition['city_name']) {
				foreach ($condition['city_type'][$city_id] as $k => $v) {
					$area[$k+1]['name'] = $condition['city_name'][$v];
					$area[$k+1]['id'] = $v;
				}
			}
		}else{
			$city_name = rtrim($_GET['city'], "市");
			foreach($condition['city_name'] as $key=>$value){
				if($value == $city_name){
					$city_id = $key;
					break;
				}
			}
			if ($condition['city_type'][$city_id] && $condition['city_name']) {
				foreach ($condition['city_type'][$city_id] as $k => $v) {
					$area[$k+1]['name'] = $condition['city_name'][$v];
					$area[$k+1]['id'] = $v;
				}
			}

		}


//			if ($condition['city_type'][$_GET['city']] && $condition['city_name']) {
//				foreach ($condition['city_type'][$_GET['city']] as $k => $v) {
//					$area[$k]['name'] = $condition['city_name'][$v];
//					$area[$k]['id'] = $v;
//				}
//			}
//        }else{
//            $msg = '未接收到城市名称';
//            $code = 1;
//        }
		$data[0]['value'] = $area;
		$data[0]['type'] = '区县';
		$data[0]['key'] = 'area_id';



		//标签
		$lable = array();
		if($condition['comdata']['job_bright'] && $condition['comclass_name']){
			foreach($condition['comdata']['job_bright'] as $k=>$v){
				$lable[$k]['name'] = $condition['comclass_name'][$v];
				$lable[$k]['id'] = $v;
			}
		}
		$data[1]['value'] = $lable;
		$data[1]['type'] = '标签';
		$data[1]['key'] = 'bright';
		//排序
		$order = array();
		$order_info = array();
		$order_info[0] = '最新';
		$order_info[1] = '推荐';
		foreach($order_info as $k=>$v){
			$order[$k]['name'] = $v;
			$order[$k]['id'] = $k;
		}
		$data[2]['value'] = $order;
		$data[2]['type'] = '排序';
		$data[2]['key'] = 'order';
		//更多
		$more = array();
		$data1 = array();
		if($condition['comdata']['job_edu'] && $condition['comclass_name']){
			foreach($condition['comdata']['job_edu'] as $k=>$v){
				$data1[$k]['name'] = $condition['comclass_name'][$v];
				$data1[$k]['id'] = $v;
//				$more[][$v] = $condition['comclass_name'][$v];
			}
			$more[0]['value'] = $data1;
			$more[0]['type'] = '学历';
			$more[0]['key'] = 'edu';
		}
		$data2 = array();
		if($condition['comdata']['job_salary'] && $condition['comclass_name']){
			foreach($condition['comdata']['job_salary'] as $k=>$v){
				$data2[$k]['name'] = $condition['comclass_name'][$v];
				$data2[$k]['id'] = $v;
			}
			$more[1]['value'] = $data2;
			$more[1]['type'] = '薪资';
			$more[1]['key'] = 'salary';
		}
		$data[3]['value'] = $more;
		$data[3]['type'] = '更多';
		$data[3]['key'] = 'more';
		/*$code = '200';
        header('Content-Type:application/json; charset=utf-8');*/

		echo json_encode(array('code'=>$code,'msg'=>$msg,'data'=>$data));
	}
	//蓝领网职位列表
	function joblist_action(){
		$CacheM=$this->MODEL('cache');
		$cachemodel=$CacheM->GetCache(array('com','user','city'));
		//定义分页相关数据star-----------
		$limit = 10;
		if($_GET['limit']){
			$limit = $_GET['limit'];
		}
		$page = 0;
		if($_GET['page']){
			$page = $_GET['page'];
		}
		$currpage = $page*$limit;
		//分页数据 end---------------

		//json附带-----------------star
		$code = 0;
		$msg = 'success';
		$data = array();
		//json附带-----------------end

		//条件处理
		$where = ' 1 and `status` != 1';
		//默认城市条件，必填
		if(!empty($_GET['city'])) {
			//处理城市名称问题 先取带‘市’的
			$city_id = '';
			foreach($cachemodel['city_name'] as $key=>$value){
				if($value == $_GET['city']){
					$city_id = $key;
					break;
				}
			}
			//查询不到相关id则截取字符‘市’进行二次查询
			if(trim($city_id) == ''){
				$city_name = rtrim($_GET['city'], "市");
				foreach($cachemodel['city_name'] as $key=>$value){
					if($value == $city_name){
						$city_id = $key;
						break;
					}
				}
			}
			$where .= " AND `cityid` = '".$city_id."' ";
		}
		//搜索
		if(trim($_GET['keyword'])!=""){
			$where .=" and  CONCAT(`com_name`,`name`) like '%".trim($_GET['keyword'])."%'";
			//记录搜索历史
			$value = '';
			if( $_GET['user_id'] ){
				$user_id_new = $this->getUser( $_GET['user_id'] );
				$value.="`user_id`='".$user_id_new['user_id']."',";
			}
			$value.="`keyword`='".$_GET['keyword']."',";
			$value.="`device_token`='".$_GET['deviceToken']."',";
			$value.="`add_time`='".time()."'";
			$this->obj->DB_insert_once("history",$value);
		}
		//地区
		if(!empty($_GET['area_id']) && $_GET['area_id']!=0){
			$where .= " AND `three_cityid` = '".$_GET['area_id']."' ";
		}
		//福利（标签）------------------
		if($_GET['bright']){
			$arr = explode(",", $_GET['bright']);
			foreach($arr as $k=>$v){
				$where .= " AND `bright` like '%".$v."%' ";
			}
		}
		//更多
		if($_GET['edu']){
			$where .= " AND `edu` = '".$_GET['edu']."' ";
		}
		if($_GET['salary']){
			switch($_GET['salary']){
				case '46';
					$where .=" and `minsalary`='0' and `maxsalary`='0' ";
					break;
				case '47';
					$where .=" and `minsalary`<'1000' ";
					break;
				case '48';
					$where .=" and `minsalary` BETWEEN '1000' and '1999' ";
					break;
				case '83';
					$where .=" and `minsalary` BETWEEN '2000' and '2999' ";
					break;
				case '49';
					$where .=" and `minsalary` BETWEEN '3000' and '4499' ";
					break;
				case '50';
					$where .=" and `minsalary` BETWEEN '4500' and '5999' ";
					break;
				case '51';
					$where .=" and `minsalary` BETWEEN '6000' and '7999' ";
					break;
				case '52';
					$where .=" and `minsalary` BETWEEN '8000' and '8999' ";
					break;
				case '53';
					$where .=" and `minsalary`>'10000' ";
					break;
			}
		}
		//增加条件(发放方式，名企招聘)
		if($_GET['salary_type']){//发放方式
			$where .= " AND `salary_type` = '".$_GET['salary_type']."' ";
		}
		if($_GET['f_company']){//名企招聘
			$where .= " AND `f_company` = '".$_GET['f_company']."' ";
		}
		//排序
		if(!empty($_GET['order']) && $_GET['order'] == 1){
			$where.=" AND `xsdate` is not null and `xsdate` >".time();
			$where.=" order by `xsdate` desc,`sdate` desc";
		}else{
			$where.=" order by `xsdate` desc,`sdate` desc";
		}
		if($_GET['salary'] && $_GET['salary']>46){
			$where.=",`maxsalary` asc";
		}


		//查询相关数据
		$CacheM=$this->MODEL('cache');
		$cachemodel=$CacheM->GetCache(array('com','user','city'));
		$totalnum = $num=$this->obj->DB_select_num("company_job",$where);
		$rows=$this->obj->DB_select_all("company_job","$where limit $currpage,$limit","id,name,company_id,com_name,three_cityid,minsalary,maxsalary,nature,bright,salary_type,f_company");
		if(!empty($rows)){
			$list = array();
			foreach($rows as $k=>$v){
				$list[$k]['id'] = $v['id'];
				$list[$k]['name'] = $v['name'];
				$list[$k]['company_id'] = $v['company_id'];
				$list[$k]['com_name'] = $v['com_name'];
				$list[$k]['minsalary'] = $v['minsalary'];
				$list[$k]['maxsalary'] = $v['maxsalary'];
				$list[$k]['salary_type'] = $v['salary_type'];
				switch ($v['salary_type']) {
					case '0';
						$list[$k]['salary_type'] = '暂无';
						$type = '未知';
						break;
					case '1';
						$list[$k]['salary_type'] = '日薪';
						$type = '日';
						break;
					case '2';
						$list[$k]['salary_type'] = '周薪';
						$type = '周';
						break;
					case '3';
						$list[$k]['salary_type'] = '月薪';
						$type = '月';
						break;
					case '4';
						$list[$k]['salary_type'] = '日薪';
						$type = '小时';
						break;
					case '5';
						$list[$k]['salary_type'] = '月三薪';
						break;
				}
				if($v['discuss'] ==1){
					$list[$k]['salary'] = '面议';
				}else{
					if($v['minsalary'] == $v['maxsalary']){
						$list[$k]['salary'] = $v['minsalary'].' 元/'.$type;
					}else{
						$list[$k]['salary'] = $v['minsalary'].' ~ '.$v['maxsalary'].' 元/'.$type;
					}
				}

				//if($v['salary_type']) {

				//}

				$list[$k]['f_company'] = $v['f_company'];
				$list[$k]['company_logo'] = '';
				if($v['company_id']){
					//2019/4/16 替换跨库为java接口
					$yingpin_model = $this->MODEL('yingpin');
					$companys = $yingpin_model->getCompanyOnce($v['company_id']);
//					$companys = $this->objlan->DB_select_once('t_enterprise',"`enterprise_id`=".$v['company_id'],"enterprise_logo,enterprise_abbreviation");
					$list[$k]['company_logo'] = $companys['enterprise_logo']?$companys['enterprise_logo']:'http://jiaxinrencai.oss-cn-beijing.aliyuncs.com/20181219/84e79653bd7e4f3e9724c677e7bf7dad.png';
					if(!empty($companys['enterprise_abbreviation'])){
						$list[$k]['com_name'] = $companys['enterprise_abbreviation'];
					}
				}
				$list[$k]['three_cityid'] = $v['three_cityid'];
				$list[$k]['city_name'] = $cachemodel['city_name'][$v['three_cityid']];

				$list[$k]['nature'] = $v['nature'];
				if($v['nature'] == 1){
					$list[$k]['nature_name'] = '全职';
				}elseif($v['nature'] == 2){
					$list[$k]['nature_name'] = '兼职';
				}else{
					$list[$k]['nature_name'] = '未知';
				}
				if($v['bright']){
					$brightarr = explode(",", $v['bright']);
					foreach($brightarr as $k2=>$v2){
						$list[$k]['bright_name'] .= $cachemodel['comclass_name'][$v2].' | ';
					}
					$list[$k]['bright_name'] = substr($list[$k]['bright_name'], 0, -3);
				}else{
					$list[$k]['bright_name'] = '暂无福利';
				}

				//公司简称
//				$company_info = $this->objlan->DB_select_once("t_enterprise",);
//				if(!empty($company_info)){
//            		foreach($company_info as $k=>$v){
//                		if(!empty($v['enterprise_abbreviation'])){
//                    		$company_info[$k]['enterprise_name'] = $v['enterprise_abbreviation'];
//                		}
//            		}
//        		}
			}
		}else{
			if($page==0 && ($_GET['city'] != "青岛" || $_GET['city'] != "青岛市") && empty($_GET['keyword']) && empty($_GET['area_id']) && empty($_GET['bright'] && empty($_GET['edu']) && empty($_GET['salary'])) && empty($_GET['salary_type']) && empty($_GET['f_company']) && empty($_GET['order'])){
				$code = 1;
				$msg = '1234';

			}else{
				$msg = '没有更多数据';
			}

		}
		if(empty($list)){
			$list = array();
		}
		$data['totalnum']=$totalnum;
		$data['pagesize'] = ceil($totalnum/$limit);
		$data['page'] = $page;
		$data['limit'] = $limit;
		$data['list'] = $list;

		echo json_encode(array('code'=>$code,'msg'=>$msg,'data'=>$data));
	}
	function citylist_action(){
		//查询已发布职位省信息
		$code = 0;
		$msg = "success";
		$CacheM=$this->MODEL('cache');
		$cachemodel=$CacheM->GetCache(array('city'));
		$city_list = $this->obj->DB_select_all("company_job"," 1","distinct provinceid");
		$city_list2 = $this->obj->DB_select_all("company_job"," 1","distinct cityid");
		$data = array();
		if(!empty($city_list)){
			foreach($city_list as $k=>$v){
				$city_info2= array();
				$city_info = $cachemodel['city_type'][$v['provinceid']];
				foreach($city_info as $k2=>$v2){
					foreach($city_list2 as $k3=>$v3){
						if($v3['cityid'] == $v2){

							$city_info2[]=$v3['cityid'];
						}
					}

				}
				if(!empty($city_info2)){
					foreach($city_info2 as $k4=>$v4){
						$data[$k]['cityList'][$k4]['city'] = $cachemodel['city_name'][$v4];
						$data[$k]['cityList'][$k4]['cityid'] = $v4;
						$data[$k]['cityList'][$k4]['father'] = $v['provinceid'];
						$data[$k]['cityList'][$k4]['id'] = $k4;
						$data[$k]['cityList'][$k4]['provice'] = null;
					}
				}
				//$data[$k]['cityList'] = $cachemodel['city_type'][$v['provinceid']];
				$data[$k]['id'] = $k;
				$data[$k]['province'] = $cachemodel['city_name'][$v['provinceid']];
				$data[$k]['provinceid'] = $v['provinceid'];
			}
		}
		echo json_encode(array("code"=>$code,"msg"=>$msg,"data"=>$data));
	}
	//浏览职位积分添加接口
	function browse_job_action(){
		$integral = 5;
		$user_id = $_POST['user_id'];
		if(!$user_id){
			echo json_encode(array("state"=>'2'));die;
		}

		//查询今天该用户的浏览+积分的计数
		$where = " 1";
		$where .= " and `uid`=".$user_id;
		$where .= " and `state`=3";
		$where .= " and `ctime` BETWEEN '".strtotime(date("Y-m-d"))."' and '".(strtotime(date("Y-m-d"))+86400)."' ";
		$browse_num = $this->obj->DB_select_num("member_reg",$where);
		if($browse_num >= 2){
			echo json_encode(array("state"=>'2'));die;
		}else{
			$where .= " and `job_id`=".$_POST['job_id'];
			$job_activy = $this->obj->DB_select_once("member_reg",$where);
			if(!empty($job_activy)){
				echo json_encode(array("state"=>'2'));die;
			}

		}
		//每天少于2则进行记录，添加积分
		$data = array();
		$data['uid'] = $user_id;
		$data['date'] = date("Y-m-d");
		$data['usertype'] = 1;//app来源
		$data['ip'] = fun_ip_get();
		$data['ctime'] = time();
		$data['job_id'] = $_POST['job_id'];
		$data['integral'] = $integral;//积分数量
		$data['msg'] = "每日浏览岗位";
		$data['state'] = 3;
		$aid=$this->obj->insert_into('member_reg',$data);
		//添加成功进行积分添加
		if($aid){
			//查询是否有该用户
			$info = $this->obj->DB_select_once("member_statis","`uid`='".$user_id."'");
			if( empty( $info ) ){
				$uid = $this->obj->insert_into("member_statis",array("uid"=>$user_id,'integral'=>$integral));
			}else{
				$uid = $this->obj->DB_update_all('member_statis',"`integral`=`integral`+'".$integral."'","`uid`='".$user_id."'");
			}
			if($uid){
				echo json_encode(array("msg"=>'浏览职位，积分+5'));die;
			}else{
				echo json_encode(array("state"=>'2'));die;
			}
		}else{
			echo json_encode(array("state"=>'2'));die;
		}

	}
	function share_integral_action(){
		$code = 1;
		$msg = '分享成功！';
		$integral = 10;
		$user_id = $_GET['user_id'];
		$job_id = $_GET['job_id'];
		if(!$user_id){
			echo json_encode(array("code"=>$code,'msg'=>'缺少用户id'));die;
		}
		//查询今天该用户的浏览+积分的计数
		$where = " 1";
		$where .= " and `uid`=".$user_id;
		$where .= " and `state`=6";
		$where .= " and `ctime` BETWEEN '".strtotime(date("Y-m-d"))."' and '".(strtotime(date("Y-m-d"))+86400)."' ";
		$browse_num = $this->obj->DB_select_num("member_reg",$where);
		if($browse_num >= 2){
			echo json_encode(array("code"=>$code,'msg'=>$msg));die;
		}
		//每天少于2则进行记录，添加积分
		$data = array();
		$data['uid'] = $user_id;
		$data['date'] = date("Y-m-d");
		$data['usertype'] = 1;//app来源
		$data['ip'] = fun_ip_get();
		$data['ctime'] = time();
		$data['job_id'] = $job_id;
		$data['integral'] = $integral;//积分数量
		$data['msg'] = "每日分享岗位";
		$data['state'] = 6;
		$aid=$this->obj->insert_into('member_reg',$data);
		//添加成功进行积分添加
		if($aid){
			//查询是否有该用户
			$info = $this->obj->DB_select_once("member_statis","`uid`='".$user_id."'");
			if( empty( $info ) ){
				$uid = $this->obj->insert_into("member_statis",array("uid"=>$user_id,'integral'=>$integral));
			}else{
				$uid = $this->obj->DB_update_all('member_statis',"`integral`=`integral`+'".$integral."'","`uid`='".$user_id."'");
			}
			if($uid){
				echo json_encode(array("code"=>$code,'msg'=>'每日分享成功，积分+10！'));die;
			}else{
				echo json_encode(array("code"=>$code,'msg'=>$msg));die;
			}
		}else{
			echo json_encode(array("code"=>$code,'msg'=>$msg));die;
		}
	}
}
?>